﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace PageOffice6_Net_Core.Controllers.InsertSeal.Word
{
    [Route("InsertSeal/Word")]
    public class WordController : Controller
    {
        private readonly IWebHostEnvironment _webHostEnvironment;

        public WordController(IWebHostEnvironment webHostEnvironment)
        {
            _webHostEnvironment = webHostEnvironment;
        }

        public IActionResult Index()
        {
            return View();
        }

        [HttpGet("AddSeal1")]
        public IActionResult AddSeal1()
        {
            string folderName = "AddSeal1";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word1.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal1.cshtml");

        }

        [HttpGet("AddSeal2")]
        public IActionResult AddSeal2()
        {
            string folderName = "AddSeal2";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word2.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal2.cshtml");

        }

        [HttpGet("AddSeal3")]
        public IActionResult AddSeal3()
        {
            string folderName = "AddSeal3";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word3.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal3.cshtml");
        }

        [HttpGet("AddSeal4")]
        public IActionResult AddSeal4()
        {
            string folderName = "AddSeal4";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word4.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal4.cshtml");
        }

        [HttpGet("AddSeal5")]
        public IActionResult AddSeal5()
        {
            string folderName = "AddSeal5";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word5.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal5.cshtml");
        }
        [HttpGet("AddSeal6")]
        public IActionResult AddSeal6()
        {
            string folderName = "AddSeal6";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word6.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal6.cshtml");
        }

        [HttpGet("AddSeal7")]
        public IActionResult AddSeal7()
        {
            string folderName = "AddSeal7";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word7.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal7.cshtml");
        }

        [HttpGet("AddSeal8")]
        public IActionResult AddSeal8()
        {
            string folderName = "AddSeal8";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word8.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal8.cshtml");

        }

        [HttpGet("AddSeal9")]
        public IActionResult AddSeal9()
        {
            string folderName = "AddSeal9";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word9.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSeal9.cshtml");

        }

        [HttpGet("DeleteSeal")]
        public IActionResult DeleteSeal()
        {
            string folderName = "DeleteSeal";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/test.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/DeleteSeal.cshtml");

        }


        [HttpGet("AddSign1")]
        public IActionResult AddSign1()
        {
            string folderName = "AddSign1";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word1.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSign1.cshtml");

        }

        [HttpGet("AddSign2")]
        public IActionResult AddSign2()
        {
            string folderName = "AddSign2";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/test.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSign2.cshtml");

        }
        [HttpGet("AddSign3")]
        public IActionResult AddSign3()
        {
            string folderName = "AddSign3";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/test.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSign3.cshtml");
        }
        [HttpGet("AddSign4")]
        public IActionResult AddSign4()
        {
            string folderName = "AddSign4";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/test.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSign4.cshtml");

         }
        

        [HttpGet("AddSign5")]
        public IActionResult AddSign5()
        {
            string folderName = "AddSign5";
            PageOfficeNetCore.PageOfficeCtrl poCtrl = new PageOfficeNetCore.PageOfficeCtrl(Request);
            //打开文件
            poCtrl.WebOpen(folderName + "/word2.doc", PageOfficeNetCore.OpenModeType.docAdmin, "张佚名");
            ViewBag.poCtrl = poCtrl.GetHtml();
            return View("~/Views/InsertSeal/Word/AddSign5.cshtml");

        }

        [HttpPost("SaveFile")]
        public async Task<ActionResult> SaveFile(String folderName)
        {
            PageOfficeNetCore.FileSaver fs = new PageOfficeNetCore.FileSaver(Request, Response);
            await fs.LoadAsync();

            string webRootPath = _webHostEnvironment.WebRootPath;
            fs.SaveToFile(webRootPath + "/InsertSeal/Word/" + folderName + "/" + fs.FileName);
            return fs.Close();

        }
    }
}
